<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ include file="../layout/tag-lib.jsp" %>

<html lang="en">
<head>
    <%@ include file="../layout/html-head.jsp"%>

    <meta charset="utf-8">
    <title>Login Page</title>

    <meta name="description" content="User login page">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>

<body class="login-layout " >

<div class="main-container container-fluid">
    <div class="main-content">
        <div class="row-fluid">
            <div class="span12">
                <div class="login-container">
                    <div class="row-fluid">
                        <div class="center" style="margin-top: 150px;">
                            <h1>
                                <i class="icon-leaf green"></i>
                                <span class="red">黑</span>
                                <span class="white">板报</span>
                            </h1>
                        </div>
                    </div>
                    <div class="space-6"></div>
                    <div class="row-fluid">
                        <div class="position-relative" style="margin-top: 80px;">
                            <div id="login-box" class="login-box visible widget-box no-border">
                                <div class="widget-body">
                                    <div class="widget-main">
                                        <h4 class="header blue lighter bigger">
                                            <i class="icon-coffee green"></i>
                                            请登录
                                        </h4>
                                        <div class="space-6"></div>
                                        <form id="login" method="post" action="/adminUser/loginSubmit">
                                            <fieldset>
                                                <label>
                                                    <span class="block input-icon input-icon-right">
                                                        <input type="text" class="span12" placeholder="用户名" name="loginName">
                                                        <i class="icon-user"></i>
                                                    </span>
                                                </label>
                                                <label>
                                                    <span class="block input-icon input-icon-right">
                                                        <input type="password" class="span12" placeholder="密码" name="loginPassword">
                                                        <i class="icon-lock"></i>
                                                    </span>
                                                </label>
                                                <div class="space"></div>
                                                <div class="clearfix">
                                                    <button onclick="login()" class="width-40 pull-left  btn btn-sm btn-primary">
                                                        <i class="icon-key"></i>
                                                        登录
                                                    </button>
                                                    <button href="#modal-form" onclick="initModal()" data-toggle="modal" class="width-40 pull-right btn btn-sm btn-primary">
                                                        <i class="ace-icon fa fa-arrow-right icon-on-right"></i>
                                                        注册
                                                    </button>
                                                </div>
                                            </fieldset>
                                        </form>
                                    </div><!-- /widget-main -->
                                </div><!-- /widget-body -->
                            </div><!-- /login-box -->
                        </div><!-- /position-relative -->
                    </div>
                </div>
            </div><!-- /.span -->
        </div><!-- /.row-fluid -->
    </div>
</div><!-- /.main-container -->


<div id="modal-form" class="modal hide" tabindex="-1" style="width: 300px;margin-left: -130px;">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="blue bigger">注册管理员</h4>
    </div>
    <div class="modal-body overflow-auto" >
        <form id="registerForm" action="/adminUser/register" method="POST" >
            <div class="control-group">
                <label class="control-label" for="loginName">用户名</label>
                <div class="controls">
                    <input style="width: 255px;" type="text" id="loginName" name="loginName" placeholder="用户名"/>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label" for="loginPassword">密码</label>
                <div class="controls">
                    <input style="width: 255px;"type="text" id="loginPassword" name="loginPassword"  placeholder="密码"></textarea>
                </div>
            </div>
            <input type="hidden" name="id"/>
        </form>
    </div>
    <div class="modal-footer">
        <button class="btn btn-small" data-dismiss="modal">
            <i class="icon-remove"></i>
            取消
        </button>
        <button class="btn btn-small btn-primary" onclick="save();">
            <i class="icon-ok"></i>
            保存
        </button>
    </div>
</div>

<!-- basic scripts -->

<!--[if !IE]> -->
<script type="text/javascript">
    window.jQuery || document.write("<script src='assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
</script><script src="assets/js/jquery-2.0.3.min.js"></script>
<!-- <![endif]-->
<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->
<script type="text/javascript">
    if("ontouchend" in document) document.write("<script src='assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
</script>
<script src="assets/js/bootstrap.min.js"></script>
<!-- page specific plugin scripts -->
<!-- ace scripts -->
<script src="assets/js/ace-elements.min.js"></script>
<script src="assets/js/ace.min.js"></script>
<!-- inline scripts related to this page -->
<jsp:include page="../layout/footer.jsp"/>
<script src="/assets/js/dropzone.min.js"></script>

<script type="text/javascript">
//    function show_box(id) {
//        jQuery('.widget-box.visible').removeClass('visible');
//        jQuery('#'+id).addClass('visible');
//    }

    function login(){
            document.getElementById("login").submit();
    }

    function initModal() {
        $("#register input[name=loginName]").val("");
        $("#register input[name=loginPassword]").val("");
    }

    function save() {
        var loginName = document.getElementById("loginName").value;
        var loginPassword = document.getElementById("loginPassword").value;
        if(loginName==null || loginName==""){
            alert("用户名不能为空！");
        }else if(loginPassword==null || loginPassword==""){
            alert("密码不能为空！");
        }else{
            $("#registerForm").submit();
        }
    }
</script>
</body></html>